home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Add-Ons / After Dark / About Box / Example Use of ADAB / Generic Module.p < prev    next >
Encoding:
Text File  |  1993-11-08  |  3.8 KB  |  124 lines  |  [TEXT/PJMM]

  1. {Generic Graphics Module}
  2.  
  3. {A very simple graphics module for After Dark™}
  4. { This source file can be used as is for both Think Pascal 4.0 and MPW Pascal 3.0  }
  5. { by Patrick Beard and Bruce Burkhalter  }
  6. { © 1989, 90, 91 Berkeley Systems Inc . }
  7.  
  8. unit GraphicsDemo;
  9.  
  10. interface
  11.  
  12.     uses
  13.         Sound, GraphicsModuleTypes, AD_About_Box;
  14.  
  15.     function DoInitialize (var storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
  16.  
  17.     function DoBlank (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
  18.  
  19.     function DoDrawFrame (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
  20.  
  21.     function DoClose (storage: Handle; blankRgn: RgnHandle; params: GMParamBlockPtr): OSErr;
  22.  
  23.     function DoHelp (params: GMParamBlockPtr): OSErr;
  24.  
  25.     function DoSetup (blankRgn: rgnHandle; message: integer; params: GMParamBlockPtr): OSErr;
  26.  
  27. implementation
  28.  
  29.     function DoInitialize (var storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
  30.     begin
  31.  
  32. {Allocate memory and initialize variables here}
  33.  
  34.         DoInitialize := noErr;
  35.  
  36.     end;
  37.  
  38.     function DoBlank (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
  39.  
  40.     begin
  41.  
  42. {Blank the screen.  You could also have "credits" appear on the screen here}
  43.  
  44.         FillRgn(blankRgn, params^.qdGlobalsCopy^.qdBlack);
  45.         DoBlank := noErr;
  46.  
  47.     end;
  48.  
  49.  
  50.     function DoDrawFrame (storage: Handle; blankRgn: rgnHandle; params: GMParamBlockPtr): OSErr;
  51.  
  52.     begin
  53.  
  54. {This function is repeatedly called by After Dark.  This is where the main drawing is done.}
  55.  
  56.         DoDrawFrame := noErr;
  57.  
  58.     end;
  59.  
  60.     function DoClose (storage: Handle; blankRgn: RgnHandle; params: GMParamBlockPtr): OSErr;
  61.     begin
  62.  
  63. {Deallocate your memory here.  You can also put something on the screen.}
  64.  
  65.         DoClose := noErr;
  66.  
  67.     end;
  68.  
  69.  
  70. {---------------DoHelp---------------------}
  71.  
  72.     function DoHelp (params: GMParamBlockPtr): OSErr;
  73.         var
  74.             PreferredFont, PreferredSize, TEXTID, CPICTID, BWPICTID, BWTextMode: integer;
  75.             CMargins, BWMargins: Rect;
  76.             RGBTEXTColor, RGBBackgroundColor: RGBColor;
  77.             depth: integer;
  78.             HelpWindowRect: Rect;
  79.             AboutBoxGrafPtr: GrafPtr;
  80.     begin
  81.  
  82.         DoHelp := noErr;
  83.         GetPort(AboutBoxGrafPtr);
  84.         HelpWindowRect := AboutBoxGrafPtr^.portRect;                   { The size of our window. }
  85.         LocalToGlobal(HelpWindowRect.topLeft);
  86.         LocalToGlobal(HelpWindowRect.botRight);
  87.         FindShallowestMonitor(depth, HelpWindowRect, params);
  88.  
  89.         PreferredFont := 20;    { Set your preferred font, 20 is Times. }
  90.         PreferredSize := 12;    { Set the type size in points. }
  91.         TEXTID := 500;            { Resource ID of the text. }
  92.         CPICTID := 500;            { Resource ID of the color PICT. }
  93.         BWPICTID := 501;        { Resource ID of the b&W PICT.  }
  94.  
  95.     { Note that the resource file provided with this project doesn't actually have any PICT resources.         }
  96.     { They were left out to keep the project size small. When ADAB can't find a PICT resource it just        }
  97.     { uses the background color instead.     }
  98.  
  99.         RGBTEXTColor.red := 0;                    { Set the text color for color mode. }
  100.         RGBTEXTColor.green := 0;
  101.         RGBTEXTColor.blue := 15000;
  102.  
  103.         RGBBackgroundColor.red := 45000;    { Always set the background color in case the PICT resource }
  104.         RGBBackgroundColor.green := 0;        { is damage or can't be used for whatever reason. }
  105.         RGBBackgroundColor.blue := 0;
  106.  
  107.         BWTextMode := 2;    { Set the color of the text in black & white mode. 1 is white, 2 is black and 3 is inverted. }
  108.  
  109.         SetRect(CMargins, 20, 10, 20, 0);            { Set your margins. CMargins.left is the number of pixels from  }
  110.         SetRect(BWMargins, 20, 10, 20, 0);        { the left edge of the window, etc. CMargins is color mode, etc.}
  111.  
  112.         DoAboutBox(PreferredFont, PreferredSize, TEXTID, CPICTID, BWPICTID, BWTextMode, Depth, CMargins, BWMargins, RGBTEXTColor, RGBBackgroundColor);
  113.     end;
  114.  
  115.     function DoSetup (blankRgn: rgnHandle; message: integer; params: GMParamBlockPtr): OSErr;
  116.     begin
  117.  
  118. {This is called when the used clicks on a button in the Control Panel.}
  119.  
  120.         DoSetup := noErr;
  121.  
  122.     end;
  123.  
  124. end.